#!/bin/sh
. /etc/sipman.conf

testReplace ()
{
  local SOURCED=$1
  local SOURCEF=$2
  local DESTD=$3
  local DESTF=$4
  local DESTEXT=$5
  if [ "$DESTEXT" = "" ]; then
    DESTEXT=org
  fi
# echo "SOURCEF=$SOURCEF, DESTD=$DESTD, DESTF=$DESTF."
  if [ ! -d "$DESTD" ]; then
    echo "Oops, no directory found for $DESTD, $DESTF not updating."
  elif [ ! -f "$SOURCED/$SOURCEF" ]; then
    echo "Oops, no source file $SOURCED/$SOURCEF found."
  elif [ -f "$DESTD/$DESTF.$DESTEXT" ]; then
    echo "File $DESTD/$DESTF already upgraded."
  else
    echo "Backupping $DESTD/$DESTF."
    mv -v $DESTD/$DESTF $DESTD/$DESTF.$DESTEXT
    if [ ! -f "$DESTD/$DESTF" ]; then
      echo "Replacing $DESTD/$DESTF."
      cp -v $SOURCED/$SOURCEF $DESTD/$DESTF
    fi
  fi
}

testMkLink ()
{
  SRC=$1
  DST=$2
  if [ ! -f $SRC ]; then
    echo "Oops, $SRC not found to link."
  elif [ -h $DST ]; then
    echo "Oke, $DST already linked."
  elif [ -f $DST ]; then
    echo "Oops, $DST found as a file."
  elif [ ! -h $DST ]; then
    echo "Creating link from $SRC to $DST."
    ln -s $SRC $DST
  fi
}


#echo "prog: $0"
BASEDIR=$SIM_BASEDIR/main/install/all
# testReplace $BASEDIR shared-configs-errorTypes /var/sipman3/shared/configs errorTypes
